{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## _*Quantum SVM algorithm:  multiclass classifier extension*_\n",
    "\n",
    "A multiclass extension works in conjunction with an underlying binary (two class) classifier to provide multiclass classification.\n",
    "\n",
    "Currently three different multiclass extensions are supported:\n",
    "\n",
    "* OneAgainstRest\n",
    "* AllPairs\n",
    "* ErrorCorrectingCode\n",
    "\n",
    "These use different techniques to group the data with binary classification to achieve the final multiclass classification."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from qiskit.ml.datasets import wine\n",
    "from qiskit import BasicAer\n",
    "from qiskit.circuit.library import ZZFeatureMap\n",
    "from qiskit.aqua import QuantumInstance, aqua_globals\n",
    "from qiskit.aqua.algorithms import QSVM\n",
    "from qiskit.aqua.components.multiclass_extensions import AllPairs\n",
    "from qiskit.aqua.utils.dataset_helper import get_feature_dimension"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here we choose the `Wine` dataset which has 3 classes."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEICAYAAABS0fM3AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nO2de7wdVZXnvz9CXkbNA9JwSSAEjSAKAnMbHKM0LxMkH0laaYi2bXzQND5axu5hCI2PNGgbms80YI8zmqERFBUjrRgn+gmPQKNolItAeHUgxtYkBohA0gIhJGHNH7UP1D236ryqzqNOre/ncz6nateuqlX73LtX7bXWXltmhuM4jlNe9uq2AI7jOE53cUXgOI5TclwROI7jlBxXBI7jOCXHFYHjOE7JcUXgOI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e+FyNR0etgeF55/fWiPQ2LnXhTOWwe8I+e/93py3RL+Dyrts6Leb9ohub4APBjufxtwWOzcD4V2XA98sJNyhf0lwNKq89rWXkQvfVvC3/ImIl/OucC54biALwWZ7ycWDZlHW3mKCcdxnJJTZtOQ4ziOgysCx3Gc0uOKwHEcp+S4InAcxyk5rggcx3FKjisCx3GckuOKwHEcp+T8f3vTmeXJfda6AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "n = 2  # dimension of each data point\n",
    "sample_Total, training_input, test_input, class_labels = wine(\n",
    "    training_size=40,\n",
    "    test_size=10, n=n, plot_data=True\n",
    ")\n",
    "temp = [test_input[k] for k in test_input]\n",
    "total_array = np.concatenate(temp)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Although the `AllPairs` extension is used here in the example the following multiclass extensions would also work:\n",
    "\n",
    "    'OneAgainstRest'\n",
    "    'ErrorCorrectingCode', 'code_size': 5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "'testing_accuracy' : 1.0\n",
      "'test_success_ratio' : 1.0\n",
      "'predicted_labels' : [0 0 1 1 1 2 2 2 2 2]\n",
      "'predicted_classes' : ['A', 'A', 'B', 'B', 'B', 'C', 'C', 'C', 'C', 'C']\n"
     ]
    }
   ],
   "source": [
    "aqua_globals.random_seed = 10598\n",
    "\n",
    "backend = BasicAer.get_backend('qasm_simulator')\n",
    "feature_map = ZZFeatureMap(feature_dimension=get_feature_dimension(training_input),\n",
    "                           reps=2, entanglement='linear')\n",
    "svm = QSVM(feature_map, training_input, test_input, total_array,\n",
    "          multiclass_extension=AllPairs())\n",
    "quantum_instance = QuantumInstance(backend, shots=1024,\n",
    "                                    seed_simulator=aqua_globals.random_seed,\n",
    "                                    seed_transpiler=aqua_globals.random_seed)\n",
    "\n",
    "result = svm.run(quantum_instance)\n",
    "for k,v in result.items():\n",
    "    print(\"'{}' : {}\".format(k, v))\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
